home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig02_26.jar
/
Ch02
/
Fig02_26
/
Fig02_26.cpp
Wrap
C/C++ Source or Header
|
1997-10-11
|
404b
|
22 lines
// Fig. 2.26: fig02_26.cpp
// Using the break statement in a for structure
#include <iostream.h>
int main()
{
// x declared here so it can be used after the loop
int x;
for ( x = 1; x <= 10; x++ ) {
if ( x == 5 )
break; // break loop only if x is 5
cout << x << " ";
}
cout << "\nBroke out of loop at x of " << x << endl;
return 0;
}